<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.ico">
    <title>Preclinic - Medical & Hospital - Bootstrap 4 Admin Template</title>
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="assets/css/style.css">
    <!--[if lt IE 9]>
		<script src="assets/js/html5shiv.min.js"></script>
		<script src="assets/js/respond.min.js"></script>
	<![endif]-->
</head>

<body>
            <div class="content">
                <div class="row">
                    <div class="col-sm-8 col-6">
                        <h4 class="page-title">请假申请</h4>
                    </div>
                    <div class="col-sm-4 col-6 text-right m-b-30">
                        <a href="add-leave.html" class="btn btn-primary btn-rounded float-right"><i class="fa fa-plus"></i> 添加请假</a>
                    </div>
                </div>
                <div class="row filter-row">
                    <div class="col-sm-6 col-md-3 col-lg-3 col-xl-2 col-12">
                        <div class="form-group form-focus">
                            <label class="focus-label">员工姓名</label>
                            <input type="text" class="form-control floating">
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3 col-lg-3 col-xl-2 col-12">
                        <div class="form-group form-focus select-focus">
                            <label class="focus-label">请假类型</label>
                            <select class="select floating" id="leaveTypes">
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3 col-lg-3 col-xl-2 col-12">
                        <div class="form-group form-focus select-focus">
                            <label class="focus-label">请假状态</label>
                            <select class="select floating">
                                <option> -- 选择 -- </option>
                                <option>等待</option>
                                <option>许可</option>
                                <option>拒绝</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3 col-lg-3 col-xl-2 col-12">
                        <div class="form-group form-focus">
                            <label class="focus-label">从</label>
                            <div class="cal-icon">
                                <input class="form-control floating datetimepicker" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3 col-lg-3 col-xl-2 col-12">
                        <div class="form-group form-focus">
                            <label class="focus-label">到</label>
                            <div class="cal-icon">
                                <input class="form-control floating datetimepicker" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-3 col-lg-3 col-xl-2 col-12">
                        <a href="#" class="btn btn-success btn-block"> 搜索 </a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="table-responsive">
                            <table class="table table-striped custom-table mb-0 datatable">
                                <thead>
                                    <tr>
                                        <th>员工姓名</th>
                                        <th>请假类型</th>
                                        <th>从</th>
                                        <th>到</th>
                                        <th>总共天数</th>
                                        <th>请假缘由</th>
                                        <th class="text-center">状态</th>
                                        <th class="text-right">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="leaves">
                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            
		<div id="delete_approve" class="modal fade delete-modal" role="dialog">
			<div class="modal-dialog modal-dialog-centered">
				<div class="modal-content">
					<div class="modal-body text-center">
						<h3>Are you sure want to delete this Leave Request?</h3>
						<div class="m-t-20"> <a href="#" class="btn btn-white" data-dismiss="modal">Close</a>
							<button type="submit" class="btn btn-danger">Delete</button>
						</div>
					</div>
				</div>
			</div>
		</div>
    <div class="sidebar-overlay" data-reff=""></div>
    <script src="assets/js/jquery-3.2.1.min.js"></script>
	<script src="assets/js/popper.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/jquery.dataTables.min.js"></script>
    <script src="assets/js/dataTables.bootstrap4.min.js"></script>
    <script src="assets/js/jquery.slimscroll.js"></script>
    <script src="assets/js/select2.min.js"></script>
    <script src="assets/js/moment.min.js"></script>
    <script src="assets/js/bootstrap-datetimepicker.min.js"></script>
    <script src="assets/js/app.js"></script>
	<!--json data-->
	<script type="text/javascript" src="json/leaves.json"></script>
	<script type="text/javascript" src="json/leaveTypes.json"></script>
	<script type="text/javascript">
	$(document).ready(function () {
		var leavesStr = "";
		for(var i = 0; i < leaves.length; i++){			
			leavesStr = leavesStr + '<tr>';
            leavesStr = leavesStr + '<td>';
            leavesStr = leavesStr + '<img width="28" height="28" src="assets/img/' + leaves[i].employeeImg +'" class="rounded-circle" alt=""/>';
            leavesStr = leavesStr + '<h2><a href="#">'+ leaves[i].employeeName +'<span>'+ leaves[i].employeeRole +'</span></a></h2>';
            leavesStr = leavesStr + '</td>';
            leavesStr = leavesStr + '<td>'+ leaves[i].type +'</td>';
            leavesStr = leavesStr + '<td>'+ leaves[i].from +'</td>';
            leavesStr = leavesStr + '<td>'+ leaves[i].to +'</td>';
            leavesStr = leavesStr + '<td>'+ leaves[i].days +'</td>';
            leavesStr = leavesStr + '<td>'+ leaves[i].reason +'</td>';
            leavesStr = leavesStr + '<td class="text-center">';
            leavesStr = leavesStr + '<div class="dropdown action-label">';
			if(leaves[i].status == '新申请'){
				leavesStr = leavesStr + '<a class="custom-badge status-purple dropdown-toggle" href="#" data-toggle="dropdown" aria-expanded="false">';
            }else if(leaves[i].status == '同意'){
				leavesStr = leavesStr + '<a class="custom-badge status-green dropdown-toggle" href="#" data-toggle="dropdown" aria-expanded="false">';
			}else if(leaves[i].status == '拒绝'){
				leavesStr = leavesStr + '<a class="custom-badge status-red dropdown-toggle" href="#" data-toggle="dropdown" aria-expanded="false">';
			}else{
				leavesStr = leavesStr + '<a class="custom-badge status-purple dropdown-toggle" href="#" data-toggle="dropdown" aria-expanded="false">';
			}
			leavesStr = leavesStr + leaves[i].status  
            leavesStr = leavesStr + '</a>';
            leavesStr = leavesStr + '<div class="dropdown-menu dropdown-menu-right">';
            leavesStr = leavesStr + '<a class="dropdown-item" href="#">新申请</a>';
            leavesStr = leavesStr + '<a class="dropdown-item" href="#">等待</a>';
            leavesStr = leavesStr + '<a class="dropdown-item" href="#">同意</a>';
            leavesStr = leavesStr + '<a class="dropdown-item" href="#">拒绝</a>';
            leavesStr = leavesStr + '</div>';
            leavesStr = leavesStr + '</div>';
            leavesStr = leavesStr + '</td>';
            leavesStr = leavesStr + '<td class="text-right">';
            leavesStr = leavesStr + '<div class="dropdown dropdown-action">';
            leavesStr = leavesStr + '<a href="#" class="action-icon dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-v"></i></a>';
            leavesStr = leavesStr + '<div class="dropdown-menu dropdown-menu-right">';
            leavesStr = leavesStr + '<a class="dropdown-item" href="edit-leave.html"><i class="fa fa-pencil m-r-5"></i> Edit</a>';
            leavesStr = leavesStr + '<a class="dropdown-item" href="#" title="Decline" data-toggle="modal" data-target="#delete_approve"><i class="fa fa-trash-o m-r-5"></i> Delete</a>';
            leavesStr = leavesStr + '</div>';
            leavesStr = leavesStr + '</div>';
            leavesStr = leavesStr + '</td>';
            leavesStr = leavesStr + '</tr>';
		}
		$("#leaves").html(leavesStr);
		
		var leaveTypesStr = "<option> -- 请选择 -- </option>";
		for(var i = 0; i < leaveTypes.length; i++){
			leaveTypesStr = leaveTypesStr + '<option value="'+leaveTypes[i].leaveType+'">'+ leaveTypes[i].leaveType +'</option>';
		}
		$("#leaveTypes").html(leaveTypesStr);
	});
	</script>
</body>

</html>